/**
 * Created by Administrator on 2017/7/30.
 */
//获取手机验证码
function getSmsCode(){
    var phoneNo = $("#phoneNo").val();
    $.ajax({
        url:"${ctxPath}/common/smsCode",
        type:"POST",
        data:{"phoneNo":phoneNo},
        dataType:"JSON",
        success:function(data){
//                logger.info(JSON.stringify(data));
            if (data.status == "200") {
                if(data.data == "lOGIN_SUCCESS"){
                    layer.msg('登录成功！'
                        ,{
                            icon: 1,
                            time: 3000, //3s后自动关闭
                            btn: ['确定']
                        }
                        , function(){
                            window.location.href = "${ctxPath}/busiOrder/dataGrid";
                        });
                }
                if(data.data == "REGISTER_SUCCESS"){
                    layer.msg('注册成功！且登陆成功'
                        ,{
                            icon: 1,
                            time: 3000, //3s后自动关闭
                            btn: ['确定']
                        }
                        , function(){
                            window.location.href = "${ctxPath}/busiOrder/dataGrid";
                        });
                }
            } else {
                if(data.data == "lOGIN_FAIL"){
                    layer.msg('登录失败！请重新输入验证码'
                        ,{
                            icon: 1,
                            time: 3000, //3s后自动关闭
                            btn: ['确定']
                        }
                        , function(){
                            window.location.href = "${ctxPath}/busiOrder/dataGrid";
                        });
                }
                if(data.data == "REGISTER_FAIL"){
                    layer.msg('注册失败'
                        ,{
                            icon: 1,
                            time: 3000, //3s后自动关闭
                            btn: ['确定']
                        }
                        , function(){
                            window.location.href = "${ctxPath}/busiOrder/dataGrid";
                        });
                }
            }
        },
        error:function(data){
            logger.error(JSON.stringify(data));
        }
    });
}

//用户登录
function login(){
    var phoneNo = $("#phoneNo").val();
    var smsCode = $("#smsCode").val();
    $.ajax({
        url:"${ctxPath}/common/smsCode",
        type:"POST",
        data:{"phoneNo":phoneNo,"smsCode":smsCode},
        dataType:"JSON",
        success:function(data){
            logger.info(JSON.stringify(data));
            if (data.status == "200") {
                layer.msg('发送成功！'
                    ,{
                        icon: 1,
                        time: 20000, //20s后自动关闭
                        btn: ['确定']
                    })
            } else {
                layer.msg('发送失败！', {icon: 1});
            }
        },
        error:function(data){
            logger.error(JSON.stringify(data));
        }
    });
}